/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package planspiel.panels.subpanels;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import planspiel.panels.GameScreen;
import admintool.imp03_data.IMP03_Tip;
/**
 *
 * @author Administrator
 */
public class GameContentTip extends JPanel{
  
    private GameScreen gameScreen = null;
    private JPanel platformParameters = null;
    private IMP03_Tip selectedTip = null;
    private Image image = null;
    
    /**
     * 
     * @param gameScreen
     */
    public GameContentTip(GameScreen gameScreen) {
        this.gameScreen = gameScreen;
        initDisplay();
        
        //Set Background Image
        try {
            BufferedImage tmpImage = new BufferedImage(1000, 800, BufferedImage.TYPE_INT_RGB);
            tmpImage = ImageIO.read(this.getClass().getResourceAsStream("/planspiel/resources/BackgroundTip.jpg"));
            this.image =  new ImageIcon(tmpImage.getScaledInstance(720, 580, Image.SCALE_SMOOTH)).getImage();
        } catch (Exception e) {
            e.printStackTrace();
        }         
    }

    @Override
    protected void paintComponent(Graphics g) {
        g.drawImage(image, 0, 0, null);
        //super.paintComponent(g);
    }
    
    private void initDisplay(){
        GroupLayout layout = new GroupLayout(this);
        this.setLayout(layout);
        
        IMP03_Tip tip =  gameScreen.getGame().getCurrentGameRoundController().getTipForCurrentStage();
        if(tip.getCosts() > 0){
            gameScreen.getGame().getGameRound().reduceScore(tip.getCosts());
        }
        
        JTextArea tipText = new JTextArea(tip.getTipText());
        tipText.setLineWrap(true);
        tipText.setWrapStyleWord(true);
        JScrollPane spTipText = new JScrollPane(tipText);
        
        platformParameters = new JPanel();
        platformParameters.setOpaque(false);
        
        layout.setHorizontalGroup(
            layout.createSequentialGroup()
                .addGap(10)
                .addComponent(spTipText) //, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(10)
        );

        layout.setVerticalGroup(
            layout.createSequentialGroup()
                .addGap(10)
                .addComponent(spTipText)
                .addGap(10)
        );
    }
}







































